package com.afinal.intelligencetrash.ui.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by cyy on 17-10-12.
 */

public abstract class BaseFragment extends Fragment{
    private View rootView;
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(getLayoutResId(), container, false);
        if (initView(rootView, savedInstanceState)){
            initData(savedInstanceState);

        }
        return rootView;
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        dealloc();
    }

    protected abstract void dealloc();

    protected abstract void initData(@Nullable Bundle savedInstanceState);

    protected abstract boolean initView(View rootView,@Nullable Bundle savedInstanceState);

    protected abstract int getLayoutResId();
}
